package com.fll.codeworld.controller;

import com.fll.codeworld.annotation.WrapResp;
import com.fll.codeworld.util.ParseJsonUtil;
import com.fll.codeworld.entity.CommonResponse;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;


/**
 * 测试controller
 * @author fll
 * @date 2022/04/25
 */
@RestController
@RequestMapping("/test")
@WrapResp
public class TestController {

    @RequestMapping("/download")
    public void download(HttpServletRequest request, HttpServletResponse response,String downloadData){
        ParseJsonUtil.writeToJson(response,"{\"id\":\"hello\"}","电能质量");
    }

    @RequestMapping("/testResponseBodyAdvice")
    public CommonResponse testResponseBodyAdvice (){
        return CommonResponse.builder().id("123").build();
    }
}
